<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算属性2</title>
</head>
<body>
<div id="weather">
    <label>
        <span>今天的天气是：{{temperature}}度</span>
    </label>
    <label>
        <span>感觉很{{feel}}</span>
    </label>
    <label>
        <button @click="changeTemperature">点击修改温度</button>
    </label>
</div>
</body>
<script src="script/vue.js"></script>
<script>
    let vue = new Vue({
        el: '#weather',
        data: {
            temperature: Math.floor(Math.random() * 50) + 1,
        },
        methods: {
            changeTemperature() {
                console.log("修改温度");
                this.temperature = Math.floor(Math.random() * 50) + 1;
            },
        },
        computed: {
            feel: function () {
                if (this.temperature > 30) {
                    return '炎热';
                } else if (this.temperature > 15 && this.temperature < 30) {
                    return '凉爽';
                } else {
                    return '寒冷';
                }
            }
        }
    })
</script>
</html>